package algorithm.poj.p1000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class P1363 {

	public static void main(String[] args) throws Exception {

		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P1363.class.getResource("P1363.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));

		StringTokenizer st = null;
		StringBuffer sb = new StringBuffer("");
		String line = stdin.readLine();
		LinkedList<Integer> stack = new LinkedList<Integer>();
        while (line != null && !"0".equals(line.trim())) {
    		line = stdin.readLine();
        	while (!"0".equals(line.trim())) {
        		st = new StringTokenizer(line);
        		stack.clear();
        		int c = 1;
        		boolean OK = true;
        		while (st.hasMoreTokens()) {
        			int t = Integer.valueOf(st.nextToken());
        			while (stack.isEmpty() || (stack.peek() < t)) {
        				stack.push(c);
        				c ++;
        			}
        			if (stack.isEmpty() || stack.peek() != t) {
        				OK = false;
        				break;
        			} else {
        				stack.pop();
        			}
        		}
        		if (OK) {
        			sb.append("Yes\n");
        		} else {
        			sb.append("No\n");
        		}
    			line = stdin.readLine();
        	}
        	sb.append("\n");
        	line = stdin.readLine();
        }
        System.out.println(sb);
	}
}
